1 /* 2 * Copyright (C) 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 ESIM_SERVICE_PROFILE_H 17 #define ESIM_SERVICE_PROFILE_H 18 19 #include <stdbool.h> 20 21 #include "asn1_builder.h" 22 #include "asn1_decoder.h" 23 #include "asn1_node.h" 24 #include "asn1_utils.h" 25 #include "esim_state_type.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 constexpr int32_t EUICC_MEMORY_RESET_BIT_STR_FILL_LEN = 0x05; 30 constexpr int32_t EUICC_MEMORY_RESET_BIT_STR_VALUE = 0xA0; 31 constexpr int32_t VERSION_BYTES_LEN = 3; 32 constexpr int32_t BASE64_TO_HEX_RATIO = 2; 33 constexpr int32_t APDU_MSG_STATUS_WAIT_RSP = 1; 34 constexpr int32_t APDU_MSG_STATUS_RCV_RSP = 2; 35 constexpr int32_t APDU_MSG_STATUS_DECODE_OK = 0; 36 constexpr int32_t SVN_RAW_LENGTH_MIN = 3; 37 constexpr int32_t EUICC_INFO_RAW_LENGTH = 1024; 38 constexpr int32_t EUICC_INFO_SVN_LENGTH = 255; 39 constexpr int32_t EUICC_INFO_VERSION_MIN_LENGTH = 3; 40 constexpr int32_t EUICC_INFO2_RAW_LENGTH = 2048; 41 constexpr int32_t EUICC_INFO2_VERSION_TYPE_LENGTH = 32; 42 constexpr int32_t EUICC_INFO2_EXT_CARD_RES_LENGTH = 128; 43 constexpr int32_t EUICC_INFO2_CAPABILITY_LENGTH = 128; 44 constexpr int32_t EUICC_INFO2_CIPKID_LIST_LENGTH = 1024; 45 constexpr int32_t EUICC_INFO2_FORBIDDEN_PROFILE_POLICY_RULES_LEN = 128; 46 constexpr int32_t EUICC_INFO2_SAS_ACCREDITATION_NUMBER_LEN = 255; 47 constexpr int32_t VERSION_HIGH = 0; 48 constexpr int32_t VERSION_MIDDLE = 1; 49 constexpr int32_t VERSION_LOW = 2; 50 constexpr int32_t ESIM_PROFILE_STATE_DISABLED = 0; 51 constexpr int32_t ESIM_PROFILE_STATE_ENABLED = 1; 52 constexpr int32_t ESIM_PROFILE_STATE_UNSPECIFIED = -1; 53 constexpr int32_t SERVICE_PROVIDER_NAME_LENGTH = 255; 54 constexpr int32_t PROFILE_NICK_NAME_LENGTH = 255; 55 constexpr int32_t PROFILE_ICCID_LENGTH = 255; 56 constexpr int32_t PROFILE_NAME_LENGTH = 255; 57 constexpr int32_t TRANSACTION_ID_LENGTH = 255; 58 constexpr int32_t CANCEL_SESSION_RESP_LEN = 1024; 59 constexpr int32_t SERVER_SIGNED1_LENGTH = 255; 60 constexpr int32_t SERVER_SIGNATURE1_LENGTH = 255; 61 constexpr int32_t EUICC_CI_PK_ID_TO_BE_USED_LENGTH = 255; 62 constexpr int32_t SERVER_CERTIFICATE_LENGTH = 2048; 63 constexpr int32_t PROFILE_ICCID_BYTE_LENGTH = 255; 64 constexpr int32_t PROFILE_ICCID_MASK_LEN = 13; 65 constexpr int32_t PROFILE_CLASS_TESTING = 0; 66 constexpr int32_t PROFILE_CLASS_PROVISIONING = 1; 67 constexpr int32_t PROFILE_CLASS_OPERATIONAL = 2; 68 constexpr int32_t PROFILE_OPERATOR_ID_MCCMNC_LEN = 10; 69 constexpr int32_t PROFILE_OPERATOR_ID_GID1_LEN = 10; 70 constexpr int32_t PROFILE_OPERATOR_ID_GID2_LEN = 10; 71 constexpr int32_t PROFILE_ICON_LENGTH = 2048; 72 constexpr int32_t AUTH_SERVER_RESPONSE_LENGTH = 10240; 73 constexpr int32_t AUTH_SERVER_TAC_LEN = 4; 74 constexpr int32_t AUTH_SERVER_IMEI_LEN = 8; 75 constexpr int32_t LAST_BYTE_OF_IMEI = 7; 76 constexpr int32_t EUICC_PRE_DOWNLOAD_RESP_MAX_LENGTH = 510; 77 constexpr int32_t SMDP_HASHCC_LENGTH = 64; 78 constexpr int32_t SMDP_SIGNED2_LENGTH = 2048; 79 constexpr int32_t SMDP_SIGNATURE2_LENGTH = 2048; 80 constexpr int32_t SMDP_CERTIFICATE_LENGTH = 2048; 81 constexpr int32_t BOUND_PROFILE_PACKAGE_MAX_LENGTH = 20480; 82 constexpr int32_t LOAD_BPP_RESULTS_LENGTH = 10240; 83 constexpr int32_t TARGET_ADDRESS_MAX_LENGTH = 128; 84 constexpr int32_t SEQUENCE_NUMBER_BYTES_NUMBER_MAX = 10; 85 constexpr int32_t NOTIF_ADDRESS_LENGTH = 255; 86 constexpr int32_t ICCID_NUMBER_MAX = 10; 87 constexpr int32_t EVENT_INSTALL = 1152; 88 constexpr int32_t CMD_HEX_MAX_DATA_LENGTH = 255; 89 90 typedef struct TagEsimProfile { 91 std::u16string iccId = u""; 92 std::u16string portIndex = u""; 93 std::u16string nickname = u""; 94 std::u16string hashCc = u""; 95 std::u16string smdpSigned2 = u""; 96 std::u16string smdpSignature2 = u""; 97 std::u16string smdpCertificate = u""; 98 int32_t seqNumber = 0; 99 bool activeAfterDown = false; 100 bool forceDisableProfile = false; 101 OHOS::Telephony::ResetOption option = OHOS::Telephony::ResetOption::DELETE_OPERATIONAL_PROFILES; 102 std::u16string transactionId = u""; 103 OHOS::Telephony::CancelReason cancelReason = OHOS::Telephony::CancelReason::CANCEL_REASON_POSTPONED; 104 std::u16string serverSigned1; 105 std::u16string serverSignature1; 106 std::u16string euiccCiPkIdToBeUsed; 107 std::u16string serverCertificate; 108 std::u16string matchingId; 109 std::u16string imei; 110 std::u16string boundProfilePackage; 111 OHOS::Telephony::Event events = OHOS::Telephony::Event::EVENT_DONOTHING; 112 std::u16string defaultSmdpAddress = u""; 113 std::u16string aid = u""; 114 EsimApduData apduData; 115 } EsimProfile; 116 117 typedef struct TagEs9PlusInitAuthResp { 118 std::string serverSigned1; 119 std::string serverSignature1; 120 std::string euiccCiPKIdToBeUsed; 121 std::string serverCertificate; 122 std::string matchingId; 123 std::string imei; 124 } Es9PlusInitAuthResp; 125 126 typedef struct TagAuthServerResponse { 127 int32_t errCode = 0; 128 std::string transactionId; 129 std::vector<uint8_t> respStr; 130 int32_t respLength = 0; 131 } AuthServerResponse; 132 133 typedef struct TagOperatorId { 134 std::string mccMnc; 135 std::string gid1; 136 std::string gid2; 137 } EsimOperatorId; 138 139 typedef struct TagEuiccProfileInfo { 140 std::string iccid; 141 std::string nickname; 142 std::string serviceProviderName; 143 std::string profileName; 144 int32_t profileClass = 0; 145 int32_t profileState = 0; 146 EsimOperatorId operatorId; 147 int32_t policyRules = 0; 148 std::list<std::shared_ptr<Asn1Node>> accessRules; 149 } EuiccProfileInfo; 150 151 typedef struct TagPrepareDownloadResp { 152 std::string hashCc; 153 std::string smdpSigned2; 154 std::string smdpSignature2; 155 std::string smdpCertificate; 156 } PrepareDownloadResp; 157 } // namespace Telephony 158 } // namespace OHOS 159 #endif // ESIM_SERVICE_PROFILE_H 160