-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_parser.h
60 lines (48 loc) · 2.33 KB
/
command_parser.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
51
52
53
54
55
56
57
58
59
60
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TRUNKS_COMMAND_PARSER_H_
#define TRUNKS_COMMAND_PARSER_H_
#include <string>
#include "trunks/tpm_generated.h"
#include "trunks/trunks_export.h"
namespace trunks {
// TPM message header size.
inline constexpr size_t kHeaderSize = 10;
// A class that parses TPM commands.
class TRUNKS_EXPORT CommandParser {
public:
virtual ~CommandParser() = default;
// Parses TPM command headers, including the session tag, the request size,
// and the command code.
virtual TPM_RC ParseHeader(std::string* command,
TPMI_ST_COMMAND_TAG* tag,
UINT32* command_size,
TPM_CC* cc) = 0;
// Parses a `TPM2_GetCapability` command, and set `cap`, `property`, and
// `property_count` to the corresponding values in the command.
// If `command` doesn't have `TPM2_GetCapability` command code, the eror
// handling is implementation defined.
virtual TPM_RC ParseCommandGetCapability(std::string* command,
TPM_CAP* cap,
UINT32* property,
UINT32* property_count) = 0;
// Parses a `TPM2_NV_Read` command, and set `auth_handle`, `nv_index`, `auth`,
// `size`, and `offset` to the corresponding values in the command.
// If `command` doesn't have `TPM2_NV_Read` command code, the error
// handling is implementation defined.
virtual TPM_RC ParseCommandNvRead(std::string* command,
TPMI_RH_NV_AUTH* auth_handle,
TPMI_RH_NV_INDEX* nv_index,
TPMS_AUTH_COMMAND* auth,
UINT16* size,
UINT16* offset) = 0;
// Parses a `TPM2_NV_ReadPublic` command, and set `nv_index` to the
// corresponding value in the command. If `command` doesn't have
// `TPM2_NV_ReadPublic` command code, the error handling is implementation
// defined.
virtual TPM_RC ParseCommandNvReadPublic(std::string* command,
TPMI_RH_NV_INDEX* nv_index) = 0;
};
} // namespace trunks
#endif // TRUNKS_COMMAND_PARSER_H_