1 //
2 // Copyright (C) 2020 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15
16 #include "tpm_auth.h"
17
18 #include <tuple>
19
20 namespace cuttlefish {
21
TpmAuth(ESYS_TR auth)22 TpmAuth::TpmAuth(ESYS_TR auth): TpmAuth(auth, ESYS_TR_NONE, ESYS_TR_NONE) {}
TpmAuth(ESYS_TR auth1,ESYS_TR auth2)23 TpmAuth::TpmAuth(ESYS_TR auth1, ESYS_TR auth2)
24 : TpmAuth(auth1, auth2, ESYS_TR_NONE) {}
TpmAuth(ESYS_TR auth1,ESYS_TR auth2,ESYS_TR auth3)25 TpmAuth::TpmAuth(ESYS_TR auth1, ESYS_TR auth2, ESYS_TR auth3) {
26 if (auth2 == ESYS_TR_NONE && auth3 != ESYS_TR_NONE) {
27 std::swap(auth2, auth3);
28 }
29 if (auth1 == ESYS_TR_NONE && auth2 != ESYS_TR_NONE) {
30 std::swap(auth1, auth2);
31 }
32 std::tie(auth1_, auth2_, auth3_) = std::make_tuple(auth1, auth2, auth3);
33 }
34
auth1() const35 ESYS_TR TpmAuth::auth1() const {
36 return auth1_;
37 }
38
auth2() const39 ESYS_TR TpmAuth::auth2() const {
40 return auth2_;
41 }
42
auth3() const43 ESYS_TR TpmAuth::auth3() const {
44 return auth3_;
45 }
46
47 } // namespace cuttlefish
48