1 // Copyright 2023 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef TRUNKS_MULTIPLE_AUTHORIZATION_DELEGATE_H_ 6 #define TRUNKS_MULTIPLE_AUTHORIZATION_DELEGATE_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "authorization_delegate.h" 12 #include "tpm_generated.h" 13 #include "trunks_export.h" 14 15 namespace trunks { 16 17 // An authorization delegate to manage multiple authorization sessions for a 18 // single command. 19 class TRUNKS_EXPORT MultipleAuthorizations : public AuthorizationDelegate { 20 public: 21 MultipleAuthorizations() = default; 22 ~MultipleAuthorizations() override = default; 23 24 // AuthorizationDelegate methods. 25 bool GetCommandAuthorization(const std::string& command_hash, 26 bool is_command_parameter_encryption_possible, 27 bool is_response_parameter_encryption_possible, 28 std::string* authorization) override; 29 bool CheckResponseAuthorization(const std::string& response_hash, 30 const std::string& authorization) override; 31 bool EncryptCommandParameter(std::string* parameter) override; 32 bool DecryptResponseParameter(std::string* parameter) override; 33 bool GetTpmNonce(std::string* nonce) override; 34 35 // Adds an authrization delegate. 36 void AddAuthorizationDelegate(AuthorizationDelegate* delegate); 37 38 private: 39 std::string ExtractSingleAuthorizationResponse(std::string* all_responses); 40 41 std::vector<AuthorizationDelegate*> delegates_; 42 }; 43 44 } // namespace trunks 45 46 #endif // TRUNKS_MULTIPLE_AUTHORIZATION_DELEGATE_H_ 47