1 /* 2 * Copyright (c) 2025 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 COMMON_NATIVE_INCLUDE_APN_PASSWORD_H 17 #define COMMON_NATIVE_INCLUDE_APN_PASSWORD_H 18 19 #include "edm_utils.h" 20 #include <climits> 21 22 namespace OHOS { 23 namespace EDM { 24 struct ApnPassword { 25 char* password = nullptr; 26 size_t passwordSize = 0; 27 static constexpr size_t MAX_PASSWORD_SIZE = UINT8_MAX; 28 29 ApnPassword() = default; 30 ~ApnPasswordApnPassword31 ~ApnPassword() 32 { 33 EdmUtils::ClearCharArray(password, passwordSize); 34 passwordSize = 0; 35 } 36 37 ApnPassword(const ApnPassword&) = delete; 38 39 ApnPassword& operator=(const ApnPassword&) = delete; 40 ApnPasswordApnPassword41 ApnPassword(ApnPassword&& other) noexcept 42 { 43 password = other.password; 44 passwordSize = other.passwordSize; 45 other.password = nullptr; 46 other.passwordSize = 0; 47 } 48 49 ApnPassword& operator=(ApnPassword&& other) noexcept 50 { 51 if (this != &other) { 52 EdmUtils::ClearCharArray(password, passwordSize); 53 password = other.password; 54 passwordSize = other.passwordSize; 55 other.password = nullptr; 56 other.passwordSize = 0; 57 } 58 return *this; 59 } 60 }; 61 } 62 } 63 #endif // COMMON_NATIVE_INCLUDE_APN_PASSWORD_H