• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
TpmAuth(ESYS_TR auth)20 TpmAuth::TpmAuth(ESYS_TR auth): TpmAuth(auth, ESYS_TR_NONE, ESYS_TR_NONE) {}
TpmAuth(ESYS_TR auth1,ESYS_TR auth2)21 TpmAuth::TpmAuth(ESYS_TR auth1, ESYS_TR auth2)
22     : TpmAuth(auth1, auth2, ESYS_TR_NONE) {}
TpmAuth(ESYS_TR auth1,ESYS_TR auth2,ESYS_TR auth3)23 TpmAuth::TpmAuth(ESYS_TR auth1, ESYS_TR auth2, ESYS_TR auth3) {
24   if (auth2 == ESYS_TR_NONE && auth3 != ESYS_TR_NONE) {
25     std::swap(auth2, auth3);
26   }
27   if (auth1 == ESYS_TR_NONE && auth2 != ESYS_TR_NONE) {
28     std::swap(auth1, auth2);
29   }
30   std::tie(auth1_, auth2_, auth3_) = std::make_tuple(auth1, auth2, auth3);
31 }
32 
auth1() const33 ESYS_TR TpmAuth::auth1() const {
34   return auth1_;
35 }
36 
auth2() const37 ESYS_TR TpmAuth::auth2() const {
38   return auth2_;
39 }
40 
auth3() const41 ESYS_TR TpmAuth::auth3() const {
42   return auth3_;
43 }
44