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 #include "attest_result_info.h" 16 17 namespace OHOS { 18 namespace DevAttest { Marshalling(Parcel & parcel) const19bool AttestResultInfo::Marshalling(Parcel &parcel) const 20 { 21 if (!parcel.WriteInt32(authResult_) || !parcel.WriteInt32(softwareResult_)) { 22 return false; 23 } 24 if (!parcel.WriteInt32(softwareResultDetail_.size()) || !parcel.WriteInt32Vector(softwareResultDetail_)) { 25 return false; 26 } 27 if (!parcel.WriteInt32(ticketLength_) || !parcel.WriteString(ticket_)) { 28 return false; 29 } 30 return true; 31 } 32 Unmarshalling(Parcel & parcel)33sptr<AttestResultInfo> AttestResultInfo::Unmarshalling(Parcel &parcel) 34 { 35 sptr<AttestResultInfo> ptr = (std::make_unique<AttestResultInfo>()).release(); 36 if (ptr == nullptr) { 37 return nullptr; 38 } 39 if (!parcel.ReadInt32(ptr->authResult_) || !parcel.ReadInt32(ptr->softwareResult_)) { 40 return nullptr; 41 } 42 int32_t setCount; 43 if (!parcel.ReadInt32(setCount) || setCount != SOFTWARE_RESULT_DETAIL_SIZE) { 44 return nullptr; 45 } 46 47 ptr->softwareResultDetail_.resize(setCount); 48 parcel.ReadInt32Vector(&ptr->softwareResultDetail_); 49 50 if (!parcel.ReadInt32(ptr->ticketLength_) || !parcel.ReadString(ptr->ticket_)) { 51 return nullptr; 52 } 53 return ptr; 54 } 55 } 56 }