blob: f7f33f949da06eb592c7473c1090ebbe73baef65 [file] [log] [blame]
Dmitry Dementyeva447b3c2017-10-27 23:09:53 -07001/*
2**
3** Copyright 2017, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#include "include/keystore/OperationResult.h"
19
20#include <binder/Parcel.h>
21#include <utility>
22
23#include "keystore_aidl_hidl_marshalling_utils.h"
24#include <keystore/keymaster_tags.h>
25
26namespace android {
27namespace security {
28namespace keymaster {
29
30using ::android::hardware::keymaster::V3_0::ErrorCode;
31using ::android::status_t;
32
33OperationResult::OperationResult() : resultCode(), token(), handle(0), inputConsumed(0), data() {}
34
35status_t OperationResult::readFromParcel(const Parcel* inn) {
36 const Parcel& in = *inn;
37 resultCode = ErrorCode(in.readInt32());
38 token = in.readStrongBinder();
39 handle = static_cast<uint64_t>(in.readInt64());
40 inputConsumed = in.readInt32();
41 data = keystore::readKeymasterBlob(in);
42 outParams = keystore::readParamSetFromParcel(in);
43 return OK;
44}
45
46status_t OperationResult::writeToParcel(Parcel* out) const {
47 out->writeInt32(resultCode);
48 out->writeStrongBinder(token);
49 out->writeInt64(handle);
50 out->writeInt32(inputConsumed);
51 keystore::writeKeymasterBlob(data, out);
52 keystore::writeParamSetToParcel(outParams, out);
53 return OK;
54}
55
56} // namespace keymaster
57} // namespace security
58} // namespace android