-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpassword_authorization_delegate.h
50 lines (39 loc) · 1.89 KB
/
password_authorization_delegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TRUNKS_PASSWORD_AUTHORIZATION_DELEGATE_H_
#define TRUNKS_PASSWORD_AUTHORIZATION_DELEGATE_H_
#include <string>
#include <base/gtest_prod_util.h>
#include "trunks/authorization_delegate.h"
#include "trunks/tpm_generated.h"
#include "trunks/trunks_export.h"
namespace trunks {
// PasswdAuthorizationDelegate is an implementation of the AuthorizationDelegate
// interface. This delegate is used for password based authorization. Upon
// initialization of this delegate, we feed in the plaintext password. This
// password is then used to authorize the commands issued with this delegate.
// This delegate performs no parameter encryption.
class TRUNKS_EXPORT PasswordAuthorizationDelegate
: public AuthorizationDelegate {
public:
explicit PasswordAuthorizationDelegate(const std::string& password);
~PasswordAuthorizationDelegate() override;
// AuthorizationDelegate methods.
bool GetCommandAuthorization(const std::string& command_hash,
bool is_command_parameter_encryption_possible,
bool is_response_parameter_encryption_possible,
std::string* authorization) override;
bool CheckResponseAuthorization(const std::string& response_hash,
const std::string& authorization) override;
bool EncryptCommandParameter(std::string* parameter) override;
bool DecryptResponseParameter(std::string* parameter) override;
bool GetTpmNonce(std::string* nonce) override;
protected:
FRIEND_TEST(PasswordAuthorizationDelegateTest, NullInitialization);
private:
TPM2B_AUTH password_;
DISALLOW_COPY_AND_ASSIGN(PasswordAuthorizationDelegate);
};
} // namespace trunks
#endif // TRUNKS_PASSWORD_AUTHORIZATION_DELEGATE_H_