-
Notifications
You must be signed in to change notification settings - Fork 3
/
type_24_hardware_security.go
62 lines (53 loc) · 1.45 KB
/
type_24_hardware_security.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
package dmi
import (
"fmt"
)
type HardwareSecurityStatus byte
const (
HardwareSecurityStatusDisabled HardwareSecurityStatus = iota
HardwareSecurityStatusEnabled
HardwareSecurityStatusNotImplemented
HardwareSecurityStatusUnknown
)
func (h HardwareSecurityStatus) String() string {
status := [...]string{
"Disabled",
"Enabled",
"Not Implemented",
"Unknown",
}
return status[h]
}
type HardwareSecuritySettings struct {
PowerOnPassword HardwareSecurityStatus
KeyboardPassword HardwareSecurityStatus
AdministratorPassword HardwareSecurityStatus
FrontPanelReset HardwareSecurityStatus
}
func NewHardwareSecurity(data byte) HardwareSecuritySettings {
var h HardwareSecuritySettings
h.PowerOnPassword = HardwareSecurityStatus(data & 0xC0)
h.KeyboardPassword = HardwareSecurityStatus(data & 0x30)
h.AdministratorPassword = HardwareSecurityStatus(data & 0x0C)
h.FrontPanelReset = HardwareSecurityStatus(data & 0x03)
return h
}
func (h HardwareSecuritySettings) String() string {
return fmt.Sprintf("Power-on Password Status: %s\n"+
"Keyboard Password Status: %s\n"+
"Administrator Password Status: %s\n"+
"Front Panel Reset Status: %s\n",
h.PowerOnPassword,
h.KeyboardPassword,
h.AdministratorPassword,
h.FrontPanelReset)
}
type HardwareSecurity struct {
infoCommon
Setting HardwareSecuritySettings
}
func (h HardwareSecurity) String() string {
return fmt.Sprintf("Hardware Security\n"+
"\tSetting: %s\n",
h.Setting)
}