• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_PASSWORD_AUTHORIZATION_DELEGATE_H_
6 #define TRUNKS_PASSWORD_AUTHORIZATION_DELEGATE_H_
7 
8 #include <string>
9 
10 #include "authorization_delegate.h"
11 #include "tpm_generated.h"
12 #include "trunks_export.h"
13 
14 namespace trunks {
15 
16 // PasswdAuthorizationDelegate is an implementation of the AuthorizationDelegate
17 // interface. This delegate is used for password based authorization. Upon
18 // initialization of this delegate, we feed in the plaintext password. This
19 // password is then used to authorize the commands issued with this delegate.
20 // This delegate performs no parameter encryption.
21 class TRUNKS_EXPORT PasswordAuthorizationDelegate
22     : public AuthorizationDelegate {
23  public:
24   explicit PasswordAuthorizationDelegate(const std::string& password);
25   PasswordAuthorizationDelegate(const PasswordAuthorizationDelegate&) = delete;
26   PasswordAuthorizationDelegate& operator=(
27       const PasswordAuthorizationDelegate&) = delete;
28 
29   ~PasswordAuthorizationDelegate() override;
30   // AuthorizationDelegate methods.
31   bool GetCommandAuthorization(const std::string& command_hash,
32                                bool is_command_parameter_encryption_possible,
33                                bool is_response_parameter_encryption_possible,
34                                std::string* authorization) override;
35   bool CheckResponseAuthorization(const std::string& response_hash,
36                                   const std::string& authorization) override;
37   bool EncryptCommandParameter(std::string* parameter) override;
38   bool DecryptResponseParameter(std::string* parameter) override;
39   bool GetTpmNonce(std::string* nonce) override;
40 
41  private:
42   TPM2B_AUTH password_;
43 };
44 
45 }  // namespace trunks
46 
47 #endif  // TRUNKS_PASSWORD_AUTHORIZATION_DELEGATE_H_
48