/
txt_control_flags.go
116 lines (95 loc) · 3.18 KB
/
txt_control_flags.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2017-2021 the LinuxBoot Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate manifestcodegen
package cbntbootpolicy
import (
"fmt"
)
type TXTControlFlags uint32
func (flags TXTControlFlags) ExecutionProfile() ExecutionProfile {
return ExecutionProfile(flags & 0x1f)
}
type ExecutionProfile uint8
const (
ExecutionProfileA = ExecutionProfile(iota)
ExecutionProfileB
ExecutionProfileC
)
// String just implements fmt.Stringer.
func (p ExecutionProfile) String() string {
switch p {
case ExecutionProfileA:
return `A (use default selection based on differentation between clients, UP, and MP servers)`
case ExecutionProfileB:
return `B (use "Server model": rely on BIOS to configure topoligy; do not use ACHECK)`
case ExecutionProfileC:
return `C (use "Client model": do not measure BIOS into D-PCRs; use ACHECK-based alias check)`
}
return fmt.Sprintf("unexpected_execution_profile_value_0x%02X", uint8(p))
}
func (flags TXTControlFlags) MemoryScrubbingPolicy() MemoryScrubbingPolicy {
return MemoryScrubbingPolicy((flags >> 5) & 0x3)
}
type MemoryScrubbingPolicy uint8
const (
MemoryScrubbingPolicyDefault = MemoryScrubbingPolicy(iota)
MemoryScrubbingPolicyBIOS
MemoryScrubbingPolicySACM
)
// String implements fmt.Stringer.
func (policy MemoryScrubbingPolicy) String() string {
switch policy {
case MemoryScrubbingPolicyDefault:
return "BIOS if verified or backup action othersize"
case MemoryScrubbingPolicyBIOS:
return "BIOS"
case MemoryScrubbingPolicySACM:
return "S-ACM"
}
return fmt.Sprintf("unexpected_value_0x%02X", uint8(policy))
}
func (flags TXTControlFlags) BackupActionPolicy() BackupActionPolicy {
return BackupActionPolicy((flags >> 7) & 0x3)
}
type BackupActionPolicy uint8
const (
BackupActionPolicyDefault = BackupActionPolicy(iota)
BackupActionPolicyForceMemoryPowerDown
BackupActionPolicyForceBtGUnbreakableShutdown
)
// String implements fmt.Stringer.
func (policy BackupActionPolicy) String() string {
switch policy {
case BackupActionPolicyDefault:
return "memory power down if profile D or BtG unbreakable shutdown otherwise"
case BackupActionPolicyForceMemoryPowerDown:
return "memory power down"
case BackupActionPolicyForceBtGUnbreakableShutdown:
return "BtG unbreakable shutdown"
}
return fmt.Sprintf("unexpected_value_0x%02X", uint8(policy))
}
// PrettyString-true: Default setting. S-ACM is requested to extend static PCRs
// PrettyString-false: S-ACM is not requested to extend static PCRs
func (flags TXTControlFlags) IsSACMRequestedToExtendStaticPCRs() bool {
return (flags>>9)&0x01 == 0
}
func (flags TXTControlFlags) ResetAUXControl() ResetAUXControl {
return ResetAUXControl((flags >> 31) & 0x01)
}
type ResetAUXControl uint8
const (
ResetAUXControlResetAUXIndex = ResetAUXControl(iota)
ResetAUXControlDeleteAUXIndex
)
// String implements fmt.Stringer.
func (c ResetAUXControl) String() string {
switch c {
case ResetAUXControlResetAUXIndex:
return "AUX reset leaf will reset AUX index"
case ResetAUXControlDeleteAUXIndex:
return "AUX reset leaf will delete AUX index"
}
return fmt.Sprintf("unexpected_value_0x%02X", uint8(c))
}